<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../node_modules/vue/dist/vue.global.js"></script>
    <style>
        ul {
            display: flex;
            list-style: none;
        }

        li {
            margin: 10px 20px;
        }

        .on {
            background-color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 导航部分 -->
        <ul>
            <li v-for="item in navList" :key="item.id" :class="activeId==item.id?'on':''" @click="activeId=item.id">
                {{item.title}}</li>
        </ul>
        <div class="content">
            <div v-for="item in contentArr" v-show="activeId==item.id">
                {{item.desc}}
            </div>
        </div>
    </div>
</body>

</html>
<script>
    const app = Vue.createApp({
        data() {
            return {
                navList: [
                    {
                        id: 1,
                        title: "综艺",
                    },
                    {
                        id: 2,
                        title: "体育"
                    },
                    {
                        id: 3,
                        title: "动漫"
                    }
                ],
                contentArr: [
                    {
                        id: 1,
                        desc: "今晚80后脱口秀"
                    },
                    {
                        id: 2,
                        desc: "NBA"
                    },
                    {
                        id: 3,
                        desc: "中华小子"
                    }
                ],
                activeId: 1 // 初始的id
            }
        },
        methods: {

        }
    }).mount('#app')

</script>